package com.kmair.caiwu.controller.kuaibao;

import com.kmair.caiwu.financialexpress.pojo.FinancialExpressFormation;
import com.kmair.caiwu.financialexpress.service.impl.FinancialExpressFormationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/subjects")
public class SubjectController {
    final FinancialExpressFormationService fefs;

    @Autowired
    public SubjectController(FinancialExpressFormationService fefs) {
        this.fefs = fefs;
    }

    @RequestMapping(method = RequestMethod.GET,produces = "application/json")
    public
    @ResponseBody
    List<FinancialExpressFormation> getAllSubjects() {
        return fefs.selectSelective(null);//获取顶级科目
    }

    @RequestMapping(method = RequestMethod.GET,produces = "text/html")
    public String showSubjects(Model model) {
        model.addAttribute(getAllSubjects());
        return "subjects";//获取顶级科目
    }

}
